#if !defined(AFX_RENDERBYOPGL_H__0BEF50E3_B4A9_4840_B014_16D0EBEED6F7__INCLUDED_)
#define AFX_RENDERBYOPGL_H__0BEF50E3_B4A9_4840_B014_16D0EBEED6F7__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// RenderByOpGL.h : header file
//
#include "Vge_3dsDataStructs.h"
#include "Vge_SceneDef.h"

/////////////////////////////////////////////////////////////////////////////
// CRenderByOpGL document

namespace ccgis{

class AFX_EXT_CLASS CRenderByOpGL : public CDocument
{
public:
	CRenderByOpGL();           // protected constructor used by dynamic creation
	DECLARE_DYNCREATE(CRenderByOpGL)
// Attributes
public:
	int NumVertex;//the total number of vertices
	VERTEX *VertexList; //the pointer to vertex array            
	int NumPolyLists; // the total number of polygons
	POLYGONLIST *PolyList;//the pointer to polygon array
//	int NumTexNofinds;//the number of texture files not found
//	int *TexNofindList;//the list of texture files not found
//	VERTEX center;//the centural coordinate of whole scene
	int DisplayListNumber;// display list index
	TRIANGLENODE **CommonTriangleList;
	double m_CenterX, m_CenterY, m_CenterZ;

protected:
	double m_xOffset, m_yOffset, m_zOffset, m_dScale;
	
// Operations
public:
	void OutGLPrepareData(H3dsScene *Scene,LPCTSTR CurrentPath, double xOffset, double yOffset, double zOffset, double dScale);
	void OutGLCompileDisplayList();

protected:
	void OutGLInitialize();
	void OutGLAddVertex(VERTEX &);
	void OutGLAddPolygon(TRIANGLES &, LPCTSTR);
	void OutGLAddMaterial(RGB &, RGB &, RGB &, LPCTSTR , LPCTSTR , LPCTSTR , int, H3dsTexture* pTexPara);
	void OutGLFinishModel();
	void FreeData();
	int  FindMaterialIndex(LPCTSTR);
	int  CalculateSurfaceNormal(SURFACE *);
	void LinkVerticesToPolygons();
	void CalculateVertexNormals();
	void MakeTriangleIndexList();
	
	BOOL FindFile(LPCTSTR lpFullFileName, LPTSTR lpFinalPath);
	int AppendMapImage(LPCTSTR filePathName);	
	BOOL LoadTexture(LPCTSTR filename);
	
	// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CRenderByOpGL)
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CRenderByOpGL();

#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	// Generated message map functions
	//{{AFX_MSG(CRenderByOpGL)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

}//end of namespace ccgis

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_RENDERBYOPGL_H__0BEF50E3_B4A9_4840_B014_16D0EBEED6F7__INCLUDED_)
